<template>
    <div class="content-center">
        <div class="content-cotainer border-box">
            <div class="content-breadcrumb">
                <el-breadcrumb separator="/" class="breadcrumb">
                    <el-breadcrumb-item :to="{ path: '/' }">审计分析</el-breadcrumb-item>
                    <el-breadcrumb-item>审计工作底稿</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
            <div class="audit-content">
                <div class="centent-title">
                    <span>{{title}}</span>
                </div>
                <!-- 页面内容 -->
                <div class="centent-inner" style="padding:15px;">
                    <el-row>
                        <el-table :data="datalist" :row-class-name="tableRowClassName" @selection-change="selectedchange" stripe>
                            <el-table-column type="selection" fixed width="50"></el-table-column>
                            <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
                            <!--<el-table-column label="审计底稿编号" prop="auditDraftId" align="center"></el-table-column>-->
                            <el-table-column label="审计底稿名称" prop="auditDraftNm" align="center" width="200px">
                                <template slot-scope="scope">
                                    <el-button type="text" @click="editdraft(scope.row.auditDraftId, scope.row.lcsCd)" >{{scope.row.auditDraftNm}}</el-button>
                                </template>
                            </el-table-column>
                            <!--<el-table-column label="审计事项" prop="auditItemDsc" align="center"></el-table-column>
                            <el-table-column label="细分审计事项" prop="auditItemDsc" align="center" width="200px"></el-table-column>
                            <el-table-column label="证据名称" prop="docNm" align="center" width="100px"></el-table-column>
                            <el-table-column label="编制日期" prop="writeDt" align="center" width="200px"></el-table-column>
                            <el-table-column label="编制人" prop="rcrdCrtpsnNm" align="center"></el-table-column>-->
                            <el-table-column label="底稿审核状态" prop="lcsCd" align="center" width="200px">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.lcsCd === '0'">编制中</span>
                                    <span v-else-if="scope.row.lcsCd === '1'">审核中</span>
                                    <span v-else-if="scope.row.lcsCd === '2'">审核通过</span>
                                    <span v-else-if="scope.row.lcsCd === '3'">审核不通过</span>
                                    <span v-else-if="scope.row.lcsCd === '4'">废弃</span>
                                </template>
                            </el-table-column>
                            <el-table-column label="修改建议" prop="relationEvd" align="center" width="200px"></el-table-column>
                        </el-table>
                    </el-row>
                    <el-pagination style="margin-top: 10px;" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 50, 100]" :page-size="10" layout="total, sizes, prev, pager, next, jumper" :total="40">
                    </el-pagination>

                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import evidenceservice from '@/api/auditoperationApi/evidenceservice'
    import axios from 'axios'
    export default {
        components: {},
        data() {
            return {
                data1: [],
                data2: [],
                dialogPermissionVisible: false,
                dialogAnnotateDscVisible: false,
                annotateTemp:{
                    annotateDsc: ''
                },
                statusTemp: {
                    auditStatusDsc: ''
                },
                auditStatus: [
                    {
                        value: '1',
                        label: '未阅'
                    }, {
                        value: '2',
                        label: '已阅'
                    }, {
                        value: '3',
                        label: '需修订'
                    }, {
                        value: '4',
                        label: '需重写'
                    }, {
                        value: '5',
                        label: '需修改'
                    }, {
                        value: '6',
                        label: '已同步'
                    }
                ],
                selectedlist: [], // 勾选数组
                lcsCdOptions: [{
                    value: '1',
                    label: '废弃'
                }, {
                    value: '0',
                    label: '编制中'
                }],
                options: [{
                    value: '1',
                    label: '事项1'
                }, {
                    value: '2',
                    label: '事项2'
                }, {
                    value: '3',
                    label: '事项3'
                }],
                title: '底稿列表',
                currentPage: 1,
                data: [{
                    b: '测试数据'
                }],
                model: {
                    event: ''
                },
                datalist: [],
                flag: false,
                form: {
                    auditDraftNm: '', // 审计底稿名称
                    auditItemDsc: '', // 审计事项
                    rcrdCrtpsnNm: '' // 编制人
                },
                newDraftForm: {
                    show: false,
                    title: '新建底稿'
                }
            }
        },
        computed: {

        },
        mounted() {
            this.getData()
        },
        methods: {
            handleDragStart(node, ev) {
                console.log('drag start', node);
            },
            handleDragEnter(draggingNode, dropNode, ev) {
                console.log('tree drag enter: ', dropNode.label);
            },
            handleDragLeave(draggingNode, dropNode, ev) {
                console.log('tree drag leave: ', dropNode.label);
            },
            handleDragOver(draggingNode, dropNode, ev) {
                console.log('tree drag over: ', dropNode.label);
            },
            handleDragEnd(draggingNode, dropNode, dropType, ev) {
                console.log('tree drag end: ', dropNode && dropNode.label, dropType);
            },
            handleDrop(draggingNode, dropNode, dropType, ev) {
                console.log('tree drop: ', dropNode.label, dropType);
            },
            reset(){
                this.form = {}
            },
            getData () {
                /*let params = {}
                axios.post('http://localhost:7111/auditWorkerDraft/findWorkDraftList', params)
                    .then(response => {
                        //resolve(response);
                        this.datalist = response.data.obj;
                    }, err => {
                        //reject(err);
                    })
                    .catch((error) => {
                        //reject(error)
                    })*/
            },

            findByParam () {
                let params = this.form
                axios.post(evidenceservice.baseUrl +'/auditWorkerDraft/findWorkDraftList', params)
                    .then(response => {
                        //resolve(response);
                        this.datalist = response.data.obj;
                    }, err => {
                        //reject(err);
                    })
                    .catch((error) => {
                        //reject(error)
                    })
            },

            deletedraft(){
                let ids= this.selectedlist.map(item => item.auditDraftId).join()
                let param = {};
                param.ids = ids ;
                param.lcsCd = '4' ;
                if(ids.length > 0){
                    this.$confirm('此操作将废弃该记录, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                    }).then(() => {
                        axios.post(evidenceservice.baseUrl +'/auditWorkerDraft/updateWorkDraftParam', param)
                            .then(response => {
                                this.$message({
                                    type: 'success',
                                    message: '维护成功'
                                });
                                this.getData();
                            }, err => {
                            })
                            .catch((error) => {
                            })
                    }).catch(action => {
                    });
                }else{
                    this.$message({
                        type: 'info',
                        message: '请选择记录'
                    });
                }
            },

            // 行索引
            tableRowClassName ({ row, rowIndex }) {
                row.index = rowIndex
            },
            selectedchange (val) {
                this.selectedlist = val
            },
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            },
            // 保存
            save() {
                this.newDraftForm.show = false
            },
        }
    }
</script>

<style lang="less" scoped>
    .content-cotainer {
        padding: 0 20px 20px 20px;
        height: 100%;
    }
</style>
